using System;
using System.Collections.Generic;
using System.Text;
using Auditing.Entities;
using Common;
using Security.Entities;
using Auditing.Data;

namespace Auditing.Business
{
    public class LogService
    {
        public static void Log(LogType type, string details)
        {
            LogDAO dao = new LogDAO();
            Log log = new Log();
            UserSession session = SessionState.Current[WebConstants.UserSession] as UserSession;

            log.LogId = Guid.NewGuid();
            log.Date = DateTime.Now;
            log.Details = details;
            log.LogTypeId = type;

            if (session == null)
            {
                log.UserId = Guid.Empty;
                log.TenantId = Guid.Empty;
            }
            else
            {
                log.UserId = session.UserId;
                log.TenantId = session.TenantId;
            }

            dao.Insert(log);
        }
    }
}
